package com.java.controller;

import com.java.config.result.Result;
import com.java.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@Api("文件管理")
@RestController
@RequestMapping("api/oss/file")
public class FileApiController {

    @Autowired
    private FileUploadService fileUploadService;


    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public Result uploadFile(MultipartFile file){
        String url = null;
        try {
            url = fileUploadService.upload(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.ok(url);
    }
}
